using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;

namespace GuiDifuso
{
    public partial class ParametrizarNorma : Form
    {
        ControladorDifuso.Normas.FabricaNormas fabricaNormas;
        ControladorDifuso.Normas.Norma normaCreada;
        ArrayList historialNormas;

        string descripcion;

        public string Descripcion
        {
            get
            {
                return this.descripcion;
            }
        }

        public ControladorDifuso.Normas.Norma Norma
        {
            get
            {
               return this.normaCreada;
            }
        }

        public ControladorDifuso.Normas.Norma obtenerDeHistorial(int indice)
        {
            return (ControladorDifuso.Normas.Norma)this.historialNormas[indice];
        }


        public ParametrizarNorma()
        {
            InitializeComponent();
            this.fabricaNormas = new ControladorDifuso.Normas.FabricaNormas();
            this.historialNormas = new ArrayList();
            this.lbxSNormas.Items.AddRange(this.fabricaNormas.Normas);
            this.lbxTNormas.Items.AddRange(this.fabricaNormas.Normas);
        }

        private void btAceptar_Click(object sender, EventArgs e)
        {
            this.Visible = false;
            this.DialogResult = DialogResult.OK;
            if (this.rBSNorma.Checked)
            {
                this.normaCreada = this.fabricaNormas.CrearS_Norma(this.lbxSNormas.SelectedItem.ToString(), this.nUParametroAlta.Value);
                this.descripcion = "SNorma " + this.lbxSNormas.SelectedItem.ToString();
            }
            else
            {
                this.normaCreada = this.fabricaNormas.CrearT_Norma(this.lbxTNormas.SelectedItem.ToString(), this.nUParametroAlta.Value);
                this.descripcion = "TNorma " + this.lbxTNormas.SelectedItem.ToString();
            }
            this.historialNormas.Add(this.normaCreada);
        }

        private void ParametrizarNorma_Load(object sender, EventArgs e)
        {
            this.rBSNorma.AutoCheck = true;
            this.lbxTNormas.SelectedIndex = 0;
            this.lbxSNormas.SelectedIndex = 0;
        }

        private void rBTNorma_CheckedChanged(object sender, EventArgs e)
        {
            this.rBSNorma.Checked = !this.rBTNorma.Checked;
        }

        private void rBSNorma_CheckedChanged(object sender, EventArgs e)
        {
            this.rBTNorma.Checked = !this.rBSNorma.Checked;
        }

        private void ParametrizarNorma_VisibleChanged(object sender, EventArgs e)
        {
            if (!this.Visible)
                this.DialogResult = DialogResult.Cancel;
        }
    }
}